// pages/list/list.js
import API from "../../api/index";
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lists:[
      {
        icon:'../../static/image/icon/menu_icon_project.png',
        title:'公域任务',
        count:0,
        url:'/pages/public_task/index'
      },
      {
        icon:'../../static/image/icon/menu_icon_PublicTask.png',
        title:'项目列表',
        count:0,
        url:"/pages/project_list/index"
      },
      {
        icon:'../../static/image/icon/menu_icon_team.png',
        title:'他人任务',
        count:0,
        url:"/pages/lichuan_team/index"
      },
      {
        icon:'../../static/image/icon/menu_icon_log.png',
        title:'日志薄',
        count:0,
        url:"/pages/journal/index"
      },
      {
        icon:'../../static/image/icon/menu_icon_management.png',
        title:'内部管理',
        count:0,
        url:"/pages/management/index"
      },
      {
        icon:'../../static/image/icon/menu_icon_doc.png',
        title:'文档资料',
        count:0,
        url:"/pages/document/index"
      }
    ],
    userinfo:{
      name:'',
      icon:''
    }
  },
  _getUserInfo(){
    API.getUserInfo().then(res=>{
      app.globalData.userInfo = res.data
      this.setData({
        ['userinfo.icon']:res.data.avatar,
        ['userinfo.name']:res.data.name
      })
    })
  },
  skip(e){
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },
  setting(){
    wx.navigateTo({
      url: "/pages/setting/index",
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  
  _getunfinish(){
    API.getunfinish().then(res=>{
        // this.setData({['lists[0].count']:res.data.job_num})
        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
          this.getTabBar().setData({
            ['list[0].count']: res.data.job_num,
            ['list[1].count']: res.data.my_num
          })
        }
    })
  },
  onShow: function () {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1
      })
    }
    this._getunfinish()
    this._getUserInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})